package com.oa.ll.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.oa.domain.Emp;
import com.oa.ll.service.GeRenService;
import com.opensymphony.xwork2.ActionSupport;




/**
 * 个人设置
 * @author liaolang
 *
 */
public class GeRenAction extends ActionSupport{
	
	private GeRenService gerenService;
   
	public void setGerenService(GeRenService gerenService) {
		this.gerenService = gerenService;
}
	private Emp emp;
	public void setEmp(Emp emp) {
		this.emp = emp;
	}
	public Emp getEmp() {
		return emp;
	}
	public GeRenService getGerenService() {
		return gerenService;
	}
 /**
 * 
 */
	public String execute() throws Exception {
		HttpSession session= ServletActionContext.getRequest().getSession();
		emp =(Emp)session.getAttribute("emp");
		emp =gerenService.getEmp(emp);
		return SUCCESS;
	}
	
/**
 * 修改用户资料
 */
public String updateEmp()throws Exception{
	HttpSession session=ServletActionContext.getRequest().getSession();
	emp=(Emp) session.getAttribute("emp");
	emp=gerenService.getEmp(emp);
	return "updateEmp";
}

public String updateEmp2()throws Exception{
	Emp e = (Emp) ServletActionContext.getRequest().getSession().getAttribute("emp");
	e.setRealname(emp.getRealname());
	e.setBirth(emp.getBirth());
	e.setEmail(emp.getEmail());
	e.setPhone(emp.getPhone());
	e.setAddr(emp.getAddr());
	gerenService.updateEmp(e);
	return "updateEmp2";
}	



 /**
   * 修改用户密码
   */
	private String updatePass()throws Exception{
		HttpSession session=ServletActionContext.getRequest().getSession();
		emp=(Emp) session.getAttribute("emp");
		emp=gerenService.getEmp(emp);
		return "updateEpass";
	}
	public String  updatePass2()throws Exception{
		gerenService.updatePass(emp);
		return "fanhui";
	}
}
